Repository navigation
Preserve source positions in parsed CQL trees - #32
Merged
adamdickmeiss merged 1 commit intoNov 20, 2026
Merged
Conversation
Track exact token boundaries in the lexer and compose source ranges in the parser, preserving original whitespace, quotes and escapes. Expose getStart() and exclusive getEnd() offsets on nodes, modifiers and sort keys. Include subtrees and enclosing parentheses in node ranges; use -1 for objects without a source location. Preserve existing public signatures and the CQLTokenizer interface. Add position regression tests, document range semantics and credit the proposal in PR #19. All 22 tests pass. Verify binary compatibility against existing API descriptors and a client compiled against the previous implementation.
adamdickmeiss
requested review from
jakub-id
and
a balanced review from Copilot
November 20, 2026 15:08
There was a problem hiding this comment.
🟢 Approval recommended
The review identifies no active issues requiring changes to the source-position metadata implementation.
No open issues 🎉
What changed in this PR
Adds source-position metadata to parsed CQL trees so callers can locate original query fragments without losing whitespace, quotes or escapes, building on the proposal in PR #19.
Changes:
- Tracks lexer token boundaries and composes parser ranges across subtrees, parentheses, prefixes and sorting.
- Exposes inclusive
getStart()and exclusivegetEnd()UTF-16 offsets while preserving existing public signatures and theCQLTokenizerinterface. - Adds position regression tests and documents range semantics, including
-1for unavailable locations.
| File | Description |
|---|---|
src/test/java/org/z3950/zing/cql/CQLSourcePositionsTest.java |
Tests source preservation, nested ranges, modifiers, sort keys and legacy lexer positions. |
src/main/java/org/z3950/zing/cql/ModifierSet.java |
Adds source ranges for bases and their modifiers, including sort keys. |
src/main/java/org/z3950/zing/cql/Modifier.java |
Adds modifier ranges that include the leading slash. |
src/main/java/org/z3950/zing/cql/CQLParser.java |
Composes source ranges from consumed token boundaries. |
src/main/java/org/z3950/zing/cql/CQLNode.java |
Adds shared node range accessors and documents their semantics. |
src/main/java/org/z3950/zing/cql/CQLLexer.java |
Exposes exact token boundaries without changing pos(). |
README.md |
Documents source-position usage and limitations, and credits PR #19. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Track exact token boundaries in the lexer and compose source ranges in the parser, preserving original whitespace, quotes and escapes.
Expose getStart() and exclusive getEnd() offsets on nodes, modifiers and sort keys. Include subtrees and enclosing parentheses in node ranges; use -1 for objects without a source location.
Preserve existing public signatures and the CQLTokenizer interface. Add position regression tests, document range semantics and credit the proposal in PR #19.
All 22 tests pass. Verify binary compatibility against existing API descriptors and a client compiled against the previous implementation.